package com.wowudi.controller;

import com.wowudi.dto.Result;
import com.wowudi.entity.Bed;
import com.wowudi.entity.House;
import com.wowudi.service.BedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "住院管理")
@RequestMapping("api/hosp/bed")
public class BedController {

    @Autowired
    private BedService bedService;

    @ApiOperation(value = "根据病房id查询病床")
    @GetMapping("getBedById/{id}")
    public Result getBedById(@PathVariable("id") String id){
        List<Bed> bedList = bedService.findBedById(id);
        Result result = new Result();
        result.setData(bedList);
        return result;
    }



    @ApiOperation(value = "新增病床")
    @PostMapping("addHouse")
    public Result addHouse(@RequestBody Bed bed){
        int i = bedService.addBed(bed);
        Result result = new Result();
        if (i==1){
            result.setMessage("新增病床成功！");
        }else{
            result.setMessage("系统繁忙！");
            result.setCode(500);
        }
        return result;
    }


}
